var timeout = null;

export default {
	data() {
		return {
			bgColor: 'transparent'
		}
	},
	onPageScroll(res) {
		let _this = this
		if (timeout !== null) clearTimeout(timeout);
		timeout = setTimeout(function() {
			console.log(res.scrollTop, _this.bgColor)
			//获取距离顶部距离
			const scrollTop = res.scrollTop;
			if (scrollTop >= 0) {
				// 导航条颜色透明渐变
				if (scrollTop <= 5) {
					_this.bgColor = 'transparent'
				} else if (scrollTop > 20) {
					_this.bgColor = '#fff'
				}
			}
		}.bind(this), 50);
	},
}
